<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 

class Contact extends MY_Controller {

	function Contact() {
        parent::MY_Controller();
    	$this->ci =& get_instance();
	}


	function index() {
		$data = $this->getData('contact');
		$data["content"] = $this->load->view('contact', '', true);
		$this->load->view('layout', $data);
	}
	
	function send() {
		$message = $this->input->post('message');

		if (strlen($message) > 0) { 
			// send email
			$this->email->from($this->ci->config->item('admin_email'), $this->ci->config->item('admin_name'));
			$this->email->reply_to($this->userdata->email, $this->userdata->name);
			$this->email->to($this->ci->config->item('admin_email'));
			$this->email->subject("Bundesligatippspiel Kontaktforumular");
			$this->email->message($message);	
			$this->email->send();

			$this->session->set_flashdata("status_type", 'info');
			$this->session->set_flashdata("status", lang('message_sent'));
		} else	{
			$this->session->set_flashdata("status_type", 'error');
			$this->session->set_flashdata("status", lang('no_message_given'));
		}	
		redirect("contact");
	}
}
?>
